﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SportsPlatform.SportBusiness.ISportBusiness;
using SportsPlatform.WeChat.IWeChat;
using System.Threading.Tasks;

namespace SportsPlatform.Web.Host.FrameworkClass
{
    public class UldAdminApplication
    {
        #region 启动业务作业

        /// <summary>
        /// 启动业务作业
        /// </summary>
        /// <returns></returns>
        public static async Task StartScheduleJobAsync(IApplicationBuilder app)
        {
            await app.ApplicationServices.GetService<IScheduleJobService>().StartScheduleJobAsync();
        }

        #endregion

        #region 加载系统缓存

        /// <summary>
        /// 加载系统缓存
        /// </summary>
        /// <returns></returns>
        public static async Task LoadSystemCache(IApplicationBuilder app)
        {
            //加载计划任务缓存
            await app.ApplicationServices.GetService<IScheduleJobService>().LoadBusinessScheduleJobCache();
        }

        #endregion

        #region 清理系统缓存

        /// <summary>
        /// 清理系统缓存
        /// </summary>
        /// <returns></returns>
        public static async Task ClearSystemCache(IApplicationBuilder app)
        {
            //清理计划任务缓存
            await app.ApplicationServices.GetService<IScheduleJobService>().ClearBusinessScheduleJobCache();
        }

        #endregion
    }
}
